import { setToken, getToken, removeToken } from '@/utils/storage'
// import { addList } from '@/api/userList'

const user = {
  namespaced: true,
  state: {
    // 刷新实现数据持久花getToken()调用一下token
    token: getToken()
  },
  mutations: {
    setToken (state, newToken) {
      // 传过来的token存到本地
      setToken(newToken)

      // 数据给到state
      state.token = newToken
      // console.log(state.token)
    },
    removeToken (state) {
      // 清空本地token
      removeToken()
      // 清空vuex里的token
      state.token = null
    }
  },
  actions: {
  }
}
export default user
